import tushare as ts
from comm.StockDaily import DbHandler
from .config import BaseDb
from comm.model import StockDaily

ts.set_token('5e9928d0932a3e94db90443dff9dc19e771d6c2ef2a5fbc1e10577a7')

#设置你的token
# df = pro.user(token='5e9928d0932a3e94db90443dff9dc19e771d6c2ef2a5fbc1e10577a7')

pro = ts.pro_api()
db = BaseDb("root", "123456", "127.0.0.1", "3306", "test")
stock_daily = DbHandler(db)

if __name__ == "__main__":
    ts_codes = stock_daily.get_all_ts_codes()
    for ts_code in ts_codes:
        last_row = stock_daily.get_last_stock_daily(ts_code)
        print(last_row.trade_date)
        # df = pro.daily(ts_code=ts_code, start_date='20250829')
        # print(df)

    # 获取指定股票从 start_date 开始的日线数据
    # df = pro.daily(ts_code='000001.SZ', start_date='20250829')

    # print(df)